<?php

use common\helpers\Url;
use yii\grid\GridView;
use common\helpers\Html;

$this->title = '工作流程';
$this->params['breadcrumbs'][] = ['label' => $this->title];

?>
<?php
raoul2000\workflow\view\WorkflowViewWidget::widget([
    'workflow' => Yii::$app->workflowSource->getWorkflow($model->id),
    'containerId' => 'workflowView'
]);
?>
<div class="row">
    <div class="col-sm-8">
        <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                <li><a href="<?= Url::to(['status/index', 'workflow_id' => $workflow_id]) ?>">流程状态</a></li>
                <li  class="active"><a href="<?= Url::to(['index', 'workflow_id' => $workflow_id]) ?>">工作流转</a></li>
                <li class="pull-right">
                    <?= Html::create(['create', 'workflow_id' => $workflow_id], '创建', [
                        'data-toggle' => 'modal',
                        'data-target' => '#ajaxModalLg',
                    ]); ?>
                </li>
            </ul>
            <div class="tab-content">
                <div class="active tab-pane">
                    <?= GridView::widget([
                        'dataProvider' => $dataProvider,
                        'filterModel' => $searchModel,
                        //重新定义分页样式
                        'tableOptions' => ['class' => 'table table-hover'],
                        'columns' => [

                            [
                                'attribute' => 'workflow_id',
                                'value' => 'workflow.title',
                            ],
                            [
                                'attribute' => 'start_status_id',
                                'value' => 'status0.label',
                            ],
                            [
                                'attribute' => 'end_status_id',
                                'value' => 'status1.label',
                            ],
//                            'start_status_id',
//                            'end_status_id',
                            [
                                'headerOptions' => ['width' => '180'],
                                'header' => "操作",
                                'class' => 'yii\grid\ActionColumn',
                                'template'=> '{edit} {delete}',
                                'buttons' => [
                                    'edit' => function ($url, $model, $key) {
                                        return Html::edit(['edit','id' => $model->id,'workflow_id' => $model->workflow_id], '编辑', [
                                            'data-toggle' => 'modal',
                                            'data-target' => '#ajaxModalLg',
                                        ]);
                                    },
                                    'delete' => function ($url, $model, $key) {
                                        return Html::delete(['delete', 'id' => $model->id,'workflow_id' => $model->workflow_id]);
                                    },
                                ],
                            ],
                        ],
                    ]); ?>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="box box-success">
            <div class="box-header with-border">
                <h3 class="box-title">流程图</h3>
            </div>
            <div class="box-body box-profile">

                <div class="col-lg-12">

                    <div id="workflowView" style="height: 400px;"></div>

                </div>
            </div>

        </div>


    </div>

</div>

